package com.scs.application.config;

import com.scs.application.interceptor.FsdInterceptor;
import com.scs.application.interceptor.QueryContextInterceptor;
import com.scs.application.modules.fsd.consts.InterceptorPath;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description：拦截器 数据源配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /*registry.addInterceptor(authenticationInterceptor())
                .addPathPatterns("/**");    // 拦截所有请求，通过判断是否有 @LoginRequired 注解 决定是否需要登录*/

        registry.addInterceptor(queryContextInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(fsdInterceptor())
                .addPathPatterns(InterceptorPath.addPathPatterns)//  拦截
                .excludePathPatterns(InterceptorPath.excludePathPatterns);   //  不拦截

    }

    /*@Bean
    public AuthenticationInterceptor authenticationInterceptor() {
        return new AuthenticationInterceptor();
    }*/

    @Bean
    public QueryContextInterceptor queryContextInterceptor() {
        return new QueryContextInterceptor();
    }

    @Bean
    public FsdInterceptor fsdInterceptor() {
        return new FsdInterceptor();
    }

}
